package main

import (
	"fmt"
	"git.oschina.net/kobeyyf/copy"
	"time"
)

func main() {
	copyer, err := copy.NewCopyer("../test/foo1", "../test/foo2", []string{"foo1", "foo2", "lndir", "foo3", "big"}, copy.ERROR_OP_INTERRUPT)
	if err != nil {
		fmt.Println(err)
		return
	}

	copyer.Count()

	for {
		if !copyer.IsDoning {
			break
		}
		time.Sleep(time.Second)
		fmt.Println(copyer.GetCountingInfo())
	}
	totalcount, totalsize, _ := copyer.GetCountingInfo()

	fmt.Println("total :", totalcount, totalsize)

	copyer.Start()

	for {
		if !copyer.IsDoning {
			break
		}

		donecount, donesize, donename, msg := copyer.GetCopingInfo()
		fmt.Println(donecount, donesize, donename, msg)

		if msg != "" {
			copyer.SetErrorOp(copy.ERROR_OP_STOP)
		}
		time.Sleep(time.Second)
	}

	fmt.Println(copyer.GetCopingInfo())

}
